import time
import urllib.parse
import re



def timenow():
    return '现在的时间是%s'%time.ctime()

def user(name):
    return '%s欢迎你的到来'%urllib.parse.unquote(name.group(1))

get_list=[('/timenow.py',timenow),('/user\.py\?user=(.+)',user)]

def app(env,func):
    info=env['name']
    for i,n in get_list:
        if i==info:
            func('200 OK',[('Service: ','Myweb')])
            return n()
        name=re.match(i,info)
        if name:
            func('200 OK',[('Service: ','Myweb')])
            return n(name)
    else:
        func('404 Not Found',[('Service: ','Myweb')])
        return '404'